<template>
  <view class="content">
    <view class="site-box">
      <view class="site-box-list" v-for="(item,index) in list" :key="index">
        <view class="site-box-list-left">
          <view class="site-h3">{{item.address}}</view>
          <view>
            <text>{{item.linkman}}</text>
            <text v-if="item.gender == '男'">先生</text>
            <text v-if="item.gender == '女'">女士</text>
            <text >{{item.phone}}</text>
          </view>
        </view>
        <view class="site-box-list-right" @click="bzhick(item.id)">
          <text v-if="item.is_default == 1">默认</text>
        </view>
      </view>
    </view>
    <view class="add-site" @click="xinzengck()">
      <text>新增收货地址</text>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
			list:''
		};
  },
  onLoad() {
		
  },
  onShow(){
    this.getList()
  },
  methods: {
    getList() {
      var than = this;
      uni.request({
        url: getApp().globalData.http + "/address/getList",
        data: "",
        method: "post",
        header: {
          "content-type": "application/x-www-form-urlencoded",
          token: uni.getStorageSync("token")
        },
        success: res => {
					console.log(res.data.data);
          if (res.data.code == 1) {
            than.list = res.data.data;
          } else {
            wx.showToast({
              title: res.data.msg,
              icon: "none",
              duration: 2000
            });
          }
        }
      });
    },
    //编辑
    bzhick(id) {
      wx.navigateTo({
        url: "/pages/my/site-edit?id=" + id
      });
    },
    //新增
    xinzengck() {
      wx.navigateTo({
        url: "/pages/my/xsite-edit"
      });
    }
  }
};
</script>
